package com.tencent.qf.team.controller;

import com.alibaba.fastjson.JSON;
import com.tencent.qf.common.pojo.HttpResult;
import com.tencent.qf.team.dal.DmAppSalesPerformanceDetail;
import com.tencent.qf.team.dal.DmAppSalesPersonalPerformance;
import com.tencent.qf.team.dal.DmAppSalesTutorPerformance;
import com.tencent.qf.team.dto.request.PerformanceSummaryByUidRequest;
import com.tencent.qf.team.dto.request.PerformanceSummaryUserDetailRequest;
import com.tencent.qf.team.dto.request.PersonalPerformanceRequest;
import com.tencent.qf.team.dto.request.TutorPerformanceByGroupIdRequest;
import com.tencent.qf.team.dto.request.TutorPerformanceRequest;
import com.tencent.qf.team.dto.response.PerformanceSummary;
import com.tencent.qf.team.service.PerformanceSummaryService;
import com.tencent.qf.team.service.SalesPerformanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Api(value = "分销单业绩归属", tags = "分销单业绩归属", protocols = "http")
public class SalesPerformanceController {

    @Autowired
    private PerformanceSummaryService performanceSummaryService;

    @PostMapping("/api/team/performanceSummary/userDetail")
    @ApiOperation("用户详情-收益订单数据")
    public HttpResult<List<DmAppSalesPerformanceDetail>> userDetail(
            @RequestBody PerformanceSummaryUserDetailRequest request) {
        log.info("用户详情-收益订单数据，入参：{}", JSON.toJSONString(request));
        List<DmAppSalesPerformanceDetail> data = performanceSummaryService.userDetail(request);
        HttpResult<List<DmAppSalesPerformanceDetail>> result = HttpResult.success(data);
        log.info("用户详情-收益订单数据，出参：{}", JSON.toJSONString(result));
        return result;
    }


    @PostMapping("/api/team/performanceSummary/userDetailByUid")
    @ApiOperation("查询订单汇总")
    public HttpResult<List<PerformanceSummary>> queryUserPerformanceSummary(
            @RequestBody PerformanceSummaryByUidRequest request) {
        log.info("查询订单汇总，入参：{}", JSON.toJSONString(request));
        List<PerformanceSummary> data = performanceSummaryService.queryUserPerformanceSummary(request);
        log.info("查询订单汇总，出参：{}", JSON.toJSONString(data));
        return HttpResult.success(data);
    }
}
